package file;

import java.io.File;
import java.io.FileFilter;
import java.util.Arrays;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : FileDemo6
 * @Author : 54061
 * @Date: 2022/2/12 15:19
 */
public class FileDemo6 {
    public static void main(String[] args) {
        //创建File对象
        File file = new File("");

        //遍历
        //File[] listFiles(FileFilter filter)
        File[] files = file.listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                return pathname.getName().endsWith(".mp4");
            }
        });
        System.out.println("files = " + Arrays.toString(files));

        for (File f : files) {
            System.out.println("f = " + f.getName());
        }
    }
}
